package com.x.client.utils

import android.content.Context
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.facade.service.SerializationService
import com.gg.utils.GsonUtil
import java.lang.reflect.Type

/**
 * Creator : GG
 * Date    : 2018/2/27
 * Mail    : gg.jin.yu@gmai.com
 * Explain :
 */
@Route(path = "/service/json")
class JsonServiceImpl : SerializationService {
    override fun <T : Any?> json2Object(input: String?, clazz: Class<T>): T = GsonUtil.fromJson(input
            ?: "", clazz)


    override fun init(context: Context?) {
    }

    override fun object2Json(instance: Any?): String = GsonUtil.toJson(instance ?: "")

    override fun <T : Any?> parseObject(input: String?, clazz: Type): T = GsonUtil.fromJson(input
            ?: "", clazz)
}